<template>
    <div class="PurchaseTakedetail flex">
        <el-table :data="takeDetailList" v-loading="takeDetailLeading" class="width font">
            <el-table-column fixed label="Model" prop="Model" width="200" />
            <el-table-column label="LeadingTime" prop="lead" width="170" />
            <el-table-column label="Qty" prop="Qtynumber" />
            <el-table-column prop="purchaser" label="Purchase" />
            <el-table-column v-if="allocationState" label="ChoosePurchase" width="150">
                <template v-slot="purcharse">
                    <el-select :disabled="purcharse.row.Qtynumber == 0 ? true : false" v-model="purcharse.row.purcharse"
                        :remote-method="(val) => { emits('getBuyerList', val) }" remote remote-show-suffix filterable>
                        <el-option v-for="item in buyerList" :key="item.id" :label="item.name" :value="item.id" />
                    </el-select>
                </template>
            </el-table-column>
            <el-table-column v-if="allocationState" label="Aqty">
                <template v-slot="quantity">
                    <el-input :disabled="quantity.row.Qtynumber == 0 ? true : false"
                        @input="() => { emits('compare', quantity.row) }" v-model="quantity.row.quantity" />
                </template>
            </el-table-column>
            <el-table-column label="Price" prop="Price" />
            <el-table-column prop="stock_number" label="Inventory" />
            <el-table-column prop="use_number" label="Available" />
            <el-table-column prop="occupy_number" label="Occupy" />
            <el-table-column label="Brand" prop="Brand_name" width="150" />
            <el-table-column align="center" fixed="right" label="Operation" width="150">
                <template v-slot="Purchaseordertesk_detailed_id">
                    <el-popconfirm confirm-button-text="Yes" cancel-button-text="No" :icon="InfoFilled" icon-color="#626AEF"
                        title="Whether to return the task?"
                        @confirm="() => { emits('returnTask', Purchaseordertesk_detailed_id) }"
                        @cancel="() => { emits('cancelEvent', 'Return cancellation') }">
                        <template #reference>
                            <el-button style="width: 60%;background-color:#6193D2;color: #fff;border: none;"
                                type="danger">ReturnTask</el-button>
                        </template>
                    </el-popconfirm>
                </template>
            </el-table-column>
        </el-table>
    </div>
</template>

<script setup>

const props = defineProps({
    takeDetailLeading: Boolean,
    takeDetailList: Object,
    state: Boolean,
    allocationState: Boolean,
    buyerList: Object
})
const emits = defineEmits(['returnTask', 'compare', 'cancelEvent', 'getBuyerList'])
</script>

<style lang="less" >
.PurchaseTakedetail {
    border-radius: 10px;
    box-sizing: border-box;
    margin-top: 1vh;
    margin-bottom: 1.5vh;

    // .el-input__inner {
    //     font-family: 'swis'
    // }

    .el-table .cell {
        padding: 0;
    }

    .width {
        width: 100%;
        height: 38vh;
        padding: 10px;
        border-radius: 10px;
    }

    .el-table .cell {
        padding-right: 10px;
    }

}
</style>